Repository navigation
Alert routes: post a firing alarm once until it really clears - #487
Merged
Merged
Conversation
A route (and any CloudWatch alarm by name) can post every time (default, and what routes saved before the setting do), once until it clears, or once with a daily reminder. Each alert's episode is stored per route and alarm ARN and changed only by version-conditioned writes, so concurrent deliveries post once. An OK starts a quiet window (30 min, or two of the alarm's evaluation spans, up to 6 h); an ALARM inside it is the same episode. The worker checks the window and the daily reminder later through chained SQS delays. Held repeats start no run and are recorded as suppressed with their episode.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
An alert route can now post an alarm that keeps firing once, instead of every time it fires (a CloudWatch alarm flapping between ALARM and OK posted on every swing). The setting is per route with per-alarm overrides; "every time" stays the default, so existing routes change nothing. Dashboard: CoderHelm/coderhelm#323 (pinned here).
Changes
repeat(every_time|until_clear|daily, missing =every_time) andalarm_repeat, a map of exact CloudWatch alarm name to setting (max 200). The override is keyed by alarm name, the same exact-name match rules use (alarm_name), rather than hung on rules: rules exist to open a PR and need a repo, so notify-only routes (where flooding hurts most) would have nowhere to put it. Plain messages use the route's setting; custom notifications and EventBridge events, which never send a recovery, always post every time.common::alert_episodes): per team, route and alert fingerprint (the alarm ARN: account, region, name),ALERT_EPISODE#<hash>: open flag, first/last notified time, fire and reminder counts, first alert id. Every change is read, a purestepdecision, then a put conditioned on the version read; a lost race re-reads and decides again, so two simultaneous deliveries post once.CLEAR_QUIET_MIN_SECS= 30 min, orCLEAR_QUIET_PERIODS(2) x the alarm's own span (Trigger.PeriodxEvaluationPeriodsfrom the SNS payload) when longer, capped at 6 h. 30 min is six 5-minute periods of calm: long enough to call a flapping alarm settled, short enough that the recovery is still news; slow alarms can't swing back sooner than their next evaluation, so they get two of their own spans. An ALARM inside the window is the same episode. After it, the episode ends, the recovery posts once (ifpost_recoveries), and the next ALARM posts at once (an ALARM arriving after the window but before the check also ends the old episode first).dailymode, one reminder card per 24 h while open (the alarm's own card, line: still firing, since when, how many times), triggered by a repeat fire or by a scheduled check for alarms stuck in ALARM; none after a clear.alert_episode_check(contract + DLQ type list updated), chained 15-minute SQS delays on the ticket queue, like the tag sweep. No infra change.Plan::Hold) never reachesdecide, so no second run; a new episode goes throughdecideunchanged, keeping theALERTSEEN6 h run dedupe. A failed run start drops the new episode so the SNS retry opens it again; a new episode deduped byALERTSEENstill posts its card with a line saying no new run.ALERT_EVENT#; episode deliveries carryepisode,episode_fires,suppressed. New outcomessuppressed,reminded,clearing(the OK's record becomesrecovered/no_open_alertwhen the window closes). Deliveries countsuppressedas ignored.close_open_alert,recovered_line,card_context) moved tocommon::alert_notifyfor the worker to share.selfhost/versions.json: dashboard pinned to the merge of AWS connections: trust the install's own account, release-pinned templates, and a live permissions check with a one-click update #323.Verification
cargo fmt --all --check,cargo clippy --workspace --all-targets -- -D warnings: clean.cargo test -p common -p gateway -p worker: all pass. New tests: flapping ALARM/OK/ALARM inside the window posts once; a real clear then a new ALARM posts again (and a duplicate or early check changes nothing); daily reminder once per 24 h while open (fire-driven and scheduled), none after clear or in until-clear mode; redeliveries count once; two concurrent deliveries post once (racing in-memory store); per-alarm override beats the route; routes without the field post every time; held repeats never start a run; failed start lets the retry reopen; request validation; quiet window bounds.